﻿<script type="text/javascript">
    $(function () {
        // Proxy created on the fly          
        var battle = $.connection.battle;

        // Declare a function on the battle hub so the server can invoke it          
        battle.client.addMessage = function (message) {
            $('#messages').append('<li>' + message + '</li>');
        };


        // Start the connection
        $.connection.hub.start().done(function () {
            $("#broadcast").click(function () {
                // Call the battle method on the server
                battle.server.send($('#msg').val());
            });

            $("#join").click(function () {
                // Call the battle method on the server
                battle.server.join();
            });
        });
    });
</script>
  
  <div>
    <input type="text" id="msg" />
      <input type="button" id="broadcast" value="broadcast" />
      <input type="button" id="join" value="join" />

<ul id="messages">
</ul>
  </div>